<ui:composition template="/dynamic/layout/layout.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="content">
		<div id="welcome">
			<p style="clear: both" />
		</div>

		<h3>Moje pliki</h3>
		<h:form id="formFiles">
			<p:dataTable id="dataTable" var="file"
				value="#{fileMBean.personalFiles}" rows="12" paginator="true"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="9,12,15" paginatorPosition="bottom"
				widgetVar="fileTable" filteredValue="#{fileMBean.filteredFiles}"
				emptyMessage="Nie znaleziono żadnych plików.">

				<f:facet name="header">
					<p:outputPanel style="float:right">
						<h:outputText value="Szukaj w plikach:" />
						<p:inputText id="globalFilter" onkeyup="fileTable.filter()"
							style="width:150px" />
					</p:outputPanel>
				</f:facet>

				<p:column sortBy="filename" headerText="Nazwa pliku" filterBy="name"
					filterMatchMode="contains">
					<h:outputText value="#{file.filename}" />
				</p:column>
				<p:column sortBy="creationDate" headerText="Data utworzenia"
					filterBy="creationDate" filterMatchMode="contains">
					<h:outputText value="#{file.creationDate}">
						<f:convertDateTime pattern="dd/MM/yyyy" />
					</h:outputText>
				</p:column>
				<p:column sortBy="dgroup.name" headerText="Grupa"
					filterBy="dgroup.name" filterMatchMode="contains">
					<h:outputText value="#{file.dgroup.name}" />
				</p:column>

				<p:column headerText="Akcje">
					<div class="action-div">
						<p:commandLink title="Pokaż" action="#{fileMBean.showFile}"
							ajax="false">
							<img
								src="${facesContext.externalContext.requestContextPath}/static/images/pokaz.PNG"
								alt="Pokaz" />
							<f:param value="#{file.idFile}" name="fileId" />
						</p:commandLink>
						<p:commandLink title="Edytuj" action="#{fileMBean.editFile}"
							ajax="false"
							rendered="#{request.isUserInRole('ROLE_ADMIN') or file.createUser.username eq userMBean.loggedUser.username}">
							<img
								src="${facesContext.externalContext.requestContextPath}/static/images/edytuj.PNG"
								alt="Edytuj" />
							<f:param value="#{file.idFile}" name="fileId" />
						</p:commandLink>
						<p:commandLink title="Usuń" action="#{fileMBean.removeFile}"
							ajax="false"
							rendered="#{request.isUserInRole('ROLE_ADMIN') or file.createUser.username eq userMBean.loggedUser.username}">
							<img
								src="${facesContext.externalContext.requestContextPath}/static/images/kosz.PNG"
								alt="Usuń" />
							<f:param value="#{file.idFile}" name="fileId" />
						</p:commandLink>
						<p:commandLink title="Pobierz" action="#{fileMBean.downloadFile}"
							ajax="false">
							<img
								src="${facesContext.externalContext.requestContextPath}/static/images/pobierz.PNG"
								alt="Pobierz" />
							<f:param value="#{file.idFile}" name="fileId" />
						</p:commandLink>
					</div>
				</p:column>
			</p:dataTable>
		</h:form>
		<div id="main_content"></div>

	</ui:define>
</ui:composition>